#include "StdAfx.h"
#include "Interval.h"


Interval::Interval(const string& startTime, const string& endTime): start(startTime), end(endTime)
{
}


Interval::~Interval(void)
{
}

string Interval::getStartTime() const
{
	return start.toString();
}

string Interval::getEndTime() const
{
	return end.toString();
}

bool Interval::isValid()
{
	if(! (start.IsValidDate() && end.IsValidDate()) )
		return false;
	if( start.Compare(end) > 0 )
		return false;
	return true;
}

bool Interval::isOverlap(const Interval& rhs)
{
	if(end.Compare(rhs.start) > 0 && start.Compare(rhs.start) < 0 || start.Compare(rhs.end) < 0 && end.Compare(rhs.start) > 0)
		return true;
	return false;
}

bool Interval::contains(const Interval& rhs)
{
	if(start.Compare(rhs.start) <= 0 && end.Compare(rhs.end) >=0)
		return true;
	return false;
}